<?php
// @formatter:off
/**
 * @file WCRssItem.php
 * @author Alejandro Dario Simi
 * @date $Date: 2013-06-22 17:58:11 +0000 (Sat, 22 Jun 2013) $
 *
 * $Id: WCRssItem.php 83 2013-06-22 17:58:11Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0-BETA2/includes/WCRssItem.php $
 */
// @formatter:on

/**
 * @class WCRssItem
 */
class WCRssItem {
	protected $_dateFormat = "r";
	protected $_values = array(
		"title" => "",
		"description" => "",
		"link" => "",
		"guid" => "",
		"pubDate" => ""
	);
	public function __construct() {
		$this->pubDate = time();
	}
	//
	// Public methods.
	public function __get($name) {
		if(!isset($this->_values[$name])) {
			trigger_error(__CLASS__.": Property '{$name}' not defined", E_USER_ERROR);
		}

		return $this->_values[$name];
	}
	public function __set($name, $value) {
		if(!isset($this->_values[$name])) {
			trigger_error(__CLASS__.": Property '{$name}' not defined", E_USER_ERROR);
		}

		$this->_values[$name] = $value;

		return $this->$name;
	}
	public function xml() {
		$out = "";

		$out .= "<item>";
		$out .= "<title>".WCRSS::Satinaze($this->title)."</title>";
		$out .= "<description>".WCRSS::Satinaze($this->description)."</description>";
		$out .= "<link>".WCRSS::Satinaze($this->link)."</link>";
		//$out .= "<guid>{$this->guid}</guid>";
		$out .= "<pubDate>".WCRSS::Satinaze(date($this->_dateFormat, $this->pubDate))."</pubDate>";
		$out .= "</item>";

		return $out;
	}
}
?>